#include"httplib.h"
#include"searchar.hpp"
#include<cstdio>
const std::string&input="data/clear/raw.txt";
const std::string root_path="./wwwroot";
int main()
{
       nasearchar::Searchar sear;
    sear.Init(input);
    std::string say;
    char an[1024];
    std::string result;
    httplib::Server server;
    server.set_base_dir(root_path.c_str());
    server.Get("/s",[&sear](const httplib::Request&req,httplib::Response&rsp)
    {
      
        if(!req.has_param("word"))
        {
            rsp.set_content("please write key word","text/plain:charset=utf-8");
            return 2;
        }
          std::string word=req.get_param_value("word");
        std::cout<<"client word:"<<word<<std::endl;
        std::string jsonstring;
        sear.Search(word,jsonstring);
    rsp.set_content(jsonstring,"application/json");
    });
    server.listen("0.0.0.0",3389);
    int x = 0;
    int y = 45;
    int g = x + y;
    return 0;
}